<?php
/*
	Muffinz CMS - A website content management system.
	Copyright (C) 2010-2011 Sigitas Zelenkovas

	This program is free software; you can redistribute it and/or
	modify it under the terms of the GNU General Public License
	as published by the Free Software Foundation; either version 2
	of the License, or (at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
	
	Optionally you can also view the license at <http://www.gnu.org/licenses/>.
*/

class Plugin_UserChat{
	private $UniqueID = "tPRsTD79O4L4eWgH73o0y1f2t2559c04";
	
	public function __construct(){
		global $cTheme, $q, $panel;

		$buffer  = "<link rel=\"stylesheet\" type=\"text/css\" href=\"{$_SESSION['sys']['core_link_full']}{$_SESSION['sys']['core_link']}includes/plugins/panels/userChat/style.css\" />";
		$buffer .= "<script type=\"text/javascript\">var pluginUserChatFullLink = \"{$_SESSION['sys']['core_link_full']}{$_SESSION['sys']['core_link']}includes/plugins/panels/userChat/\";</script><script type=\"text/javascript\" src=\"{$_SESSION['sys']['core_link_full']}{$_SESSION['sys']['core_link']}includes/plugins/panels/userChat/script.js\"></script>";
		if(isset($_SESSION['user'])){
			$buffer .= "<div class=\"pluginUserChatPostBox\">Char limit: {$_SESSION['sys']['core_shoutbox_minlen']}-{$_SESSION['sys']['core_shoutbox_maxlen']}<br /><textarea id=\"pluginUserChatText\"></textarea><br /><input type=\"button\" class=\"button\" value=\"Send\" id=\"pluginUserChatButton\" /></div>";
		}else {
			$buffer .= "<div class=\"pluginUserChatPostBox\">Login to use this chat.</div>";	
		}
		$buffer .= "<div class=\"pluginUserChat\"></div>";
		$cTheme->AddPanel("User chat", $buffer, $panel->GetPlace($this->UniqueID));
	}
		
	public function Install(){
		global $q;
		$q->Send("CREATE TABLE `plugin_userchat` (`id` INT( 64 ) NOT NULL AUTO_INCREMENT PRIMARY KEY, `userid` INT( 64 ) NOT NULL, `text` LONGTEXT NOT NULL)");
	}
	
	public function Uninstall(){
		
	}
}
